//
//  HotCell.m
//  ProjectForA
//
//  Created by 靖哥哥 on 14/11/19.
//  Copyright (c) 2014年 hmengwei. All rights reserved.
//

#import "HotCell.h"
#import "RecommendModel.h"
#import "UIImageView+WebCache.h"

@implementation HotCell


#pragma mark -
#pragma mark 内存管理
- (void)dealloc
{
    [_hotImageView release];
    [_hotTitle release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        
        
        
        self.hotImageView = [[UIImageView alloc] init];
        _hotImageView.backgroundColor = [UIColor redColor];
        _hotImageView.layer.cornerRadius = 20;
        _hotImageView.layer.masksToBounds = YES;
        [self addSubview:_hotImageView];
        [_hotImageView release];
        
        
        self.hotTitle = [[UILabel alloc] init];
        _hotTitle.font = [UIFont systemFontOfSize:23];
        _hotTitle.textColor = [UIColor whiteColor];
        [self addSubview:_hotTitle ];
        [_hotTitle release];
        
        
        
        [self addObserver:self forKeyPath:@"model" options:NSKeyValueObservingOptionNew context:nil];
        
        
    }
    return self;
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    if ([keyPath isEqualToString:@"model"]) {
        
        [self.hotImageView setImageWithURL:[NSURL URLWithString:self.model.cover_image]];

        
        
    }
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.hotImageView.frame = CGRectMake(0, 0, self.frame.size.width, 190);
    self.hotTitle.frame = CGRectMake(30, 10, self.frame.size.width / 2, 40);
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
